0311ebcd7dee50d46dcaf7cbe560ea918ad4a0eb
3 * A foreign repository with an accessible MediaWiki database
10 * A foreign repository with an accessible MediaWiki database
14 class ForeignDBRepo
extends LocalRepo
{
16 var $dbType, $dbServer, $dbUser, $dbPassword, $dbName, $dbFlags,
17 $tablePrefix, $hasSharedCache;
21 var $fileFactory = array( 'ForeignDBFile', 'newFromTitle' );
22 var $fileFromRowFactory = array( 'ForeignDBFile', 'newFromRow' );
24 function __construct( $info ) {
25 parent
::__construct( $info );
26 $this->dbType
= $info['dbType'];
27 $this->dbServer
= $info['dbServer'];
28 $this->dbUser
= $info['dbUser'];
29 $this->dbPassword
= $info['dbPassword'];
30 $this->dbName
= $info['dbName'];
31 $this->dbFlags
= $info['dbFlags'];
32 $this->tablePrefix
= $info['tablePrefix'];
33 $this->hasSharedCache
= $info['hasSharedCache'];
36 function getMasterDB() {
37 if ( !isset( $this->dbConn
) ) {
38 $this->dbConn
= DatabaseBase
::factory( $this->dbType
,
40 'host' => $this->dbServer
,
41 'user' => $this->dbUser
,
42 'password' => $this->dbPassword
,
43 'dbname' => $this->dbName
,
44 'flags' => $this->dbFlags
,
45 'tablePrefix' => $this->tablePrefix
52 function getSlaveDB() {
53 return $this->getMasterDB();
56 function hasSharedCache() {
57 return $this->hasSharedCache
;
61 * Get a key on the primary cache for this repository.
62 * Returns false if the repository's cache is not accessible at this site.
63 * The parameters are the parts of the key, as for wfMemcKey().
65 function getSharedCacheKey( /*...*/ ) {
66 if ( $this->hasSharedCache() ) {
67 $args = func_get_args();
68 array_unshift( $args, $this->dbName
, $this->tablePrefix
);
69 return call_user_func_array( 'wfForeignMemcKey', $args );
75 function store( $srcPath, $dstZone, $dstRel, $flags = 0 ) {
76 throw new MWException( get_class($this) . ': write operations are not supported' );
78 function publish( $srcPath, $dstRel, $archiveRel, $flags = 0 ) {
79 throw new MWException( get_class($this) . ': write operations are not supported' );
81 function deleteBatch( $sourceDestPairs ) {
82 throw new MWException( get_class($this) . ': write operations are not supported' );